﻿package mortal.game.scene3D.player.head
{
    import Message.DB.Tables.*;
    import baseEngine.core.*;
    import baseEngine.modifiers.*;
    import flash.text.*;
    import mortal.common.global.*;
    import mortal.game.resource.tableConfig.*;
    import mortal.game.scene3D.display3d.text3d.dynamicText3d.*;
    import mortal.game.scene3D.layer3D.*;
    import mortal.game.scene3D.model.player.*;
    import mortal.game.scene3D.model.pools.*;
    import mortal.game.view.common.*;

    public class HeadTitle extends Pivot3D
    {
        protected var _titleEffect:EffectPlayer;
        protected var _titleText:Text3D;
        protected var _titleId:int;
        protected var _height:Number = 20;
        private static var textField:TextField;

        public function HeadTitle()
        {
            super("");
            createTextField();
            return;
        }// end function

        private function updateText(param1:Text3D, param2:String) : Text3D
        {
            textField.htmlText = param2;
            if (!param1)
            {
                param1 = Text3DFactory.instance.createtext3D(textField, false, this);
            }
            else
            {
                Text3DFactory.instance.updateText3D(param1, textField, this);
            }
            return param1;
        }// end function

        public function updateTitle(param1:int) : void
        {
            var _loc_2:TTitle = null;
            var _loc_3:String = null;
            var _loc_4:int = 0;
            if (this._titleId == param1)
            {
                return;
            }
            this._titleId = param1;
            if (!_loc_2)
            {
            }
            switch(_loc_2.pictureType)
            {
                case 0:
                {
                    if (this._titleEffect)
                    {
                    }
                    break;
                }
                case 1:
                {
                    if (this._titleEffect)
                    {
                    }
                    if (this._titleText)
                    {
                    }
                    break;
                }
                case 2:
                {
                    if (this._titleEffect)
                    {
                    }
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

        public function get height() : Number
        {
            return this._height;
        }// end function

        public function clear() : void
        {
            if (this._titleText)
            {
                Text3DFactory.instance.disposeText3D(this._titleText);
                this._titleText = null;
            }
            if (this._titleEffect)
            {
                this._titleEffect.dispose();
                this._titleEffect = null;
            }
            this._titleId = 0;
            return;
        }// end function

        protected function updateVisible(param1:Boolean) : void
        {
            if (this._titleText)
            {
                if (param1)
                {
                    this._titleText.show();
                }
                else
                {
                    this._titleText.hide();
                }
            }
            return;
        }// end function

        private static function createTextField() : void
        {
            if (!textField)
            {
                textField = UIFactory.textField("", 0, 0, -1, -1, null, GlobalStyle.textFormatItemWhite);
                textField.autoSize = TextFieldAutoSize.LEFT;
            }
            return;
        }// end function

    }
}
